from django.contrib import admin
from .models import AdminLog, SystemConfig, Statistics

@admin.register(AdminLog)
class AdminLogAdmin(admin.ModelAdmin):
    list_display = ('admin', 'action_type', 'target_story', 'target_user', 'created_at')
    list_filter = ('action_type', 'created_at')
    search_fields = ('admin__username', 'description', 'target_story__title', 'target_user__username')
    date_hierarchy = 'created_at'
    readonly_fields = ('admin', 'action_type', 'target_story', 'target_user', 'report', 'description', 'created_at')

@admin.register(SystemConfig)
class SystemConfigAdmin(admin.ModelAdmin):
    list_display = ('key', 'updated_at')
    search_fields = ('key', 'description')
    readonly_fields = ('updated_at',)

@admin.register(Statistics)
class StatisticsAdmin(admin.ModelAdmin):
    list_display = ('date', 'daily_active_users', 'new_users', 'new_stories', 'total_views', 'total_likes', 'total_comments')
    list_filter = ('date',)
    date_hierarchy = 'date'
    readonly_fields = ('date', 'daily_active_users', 'new_users', 'new_stories', 'total_views', 'total_likes', 'total_comments')
